package org.itboys.core.controller.web.coupon;

import org.itboys.core.entity.mysql.coupon.record.SundayMemberCoupon;
import org.itboys.core.service.mysql.web.SundayCouponRecordService;
import org.itboys.core.util.MybatisParamUtil;
import org.itboys.framework.query.JsonPageUtils;
import org.itboys.param.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author：贾琦磊
 * @Date：2018/12/10
 * @Description：优惠券使用情况
 */
@Controller
@RequestMapping("/sunday/web/coupon/record")
public class SundayCouponRecordController {
    @Autowired
    private SundayCouponRecordService couponRecordService;
    @RequestMapping("/index")
    public String index(HttpServletRequest request, HttpServletResponse response) {
        return "/sunday/coupon/record/index";
    }

    @RequestMapping("/select")
    public void select(HttpServletRequest request, HttpServletResponse response
    , @RequestParam("used")Integer used) {
        MybatisParamUtil paramUtil = new MybatisParamUtil(request);
        PageResult<SundayMemberCoupon> result = couponRecordService.select(paramUtil,used);
        JsonPageUtils.renderJsonPage(result.getTotal(), result.getData(), response);
    }
}
